<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>图片切换</title>
	</head>
	<body>
		<div id="d1">
			<img id="i1" src="img/图片切换/1.jpg">
		</div>
		<button type="button" onclick="star()">开始</button>
	</body>
	<script type="text/javascript">
		function star() {
			var img1 = document.getElementById('i1');
			var index=1;
			
			setInterval(function(){
				index++;
				img1.src=`img/图片切换/`+index+`.jpg`;
			if(index==9){
				img1.src=`img/图片切换/`+index+`.jpg`;
				index=0;
				console.log('重新开始循环！')
			}
			},2000)
		}
	</script>
</html>
